import { fileURLToPath, URL } from "node:url";
import AutoImport from 'unplugin-auto-import/vite'
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/vite";
import Autoprefixer from  "autoprefixer"
import Tailwindcss from  "tailwindcss"
export default defineConfig({
    plugins: [vue(), vueJsx(),
        Components({
            resolvers: [
                AntDesignVueResolver({
                    importStyle: false // css in js
                })
            ]
        })
        , AutoImport({
        include: [ // 包含哪些文件。
            /\.[tj]sx?$/,
            /\.vue$/,
            /\.vue\?vue/
        ],
        // global imports to register
        imports: [
            // 插件预设支持导入的api
            'vue',
            "vue-router",
            'pinia',
            // 自定义导入的api
            {
                'axios': [
                    // default imports
                    ['default', 'axios'], // import { default as axios } from 'axios',
                ],
            }
        ],
        dts: './auto-imports.d.ts',  // 生成在src路径下路径名为 auto-import.d.ts的声明文件
    })],
    resolve: {
        alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
        },
    },
    css:{
        postcss:{
            plugins:[
                Tailwindcss,Autoprefixer
            ]
        }
    },
    base:"./",
    build: {},
    server: {
        host: "0.0.0.0",
        port: 3000,
        proxy: {
            "/api": {
                target: "http://192.168.1.65:5000"
            }
        }
    },
});
